/*
-----
标题问候脚本 
by:Darryl
-----
*/
var keyWords = document.title;
var Ctime = 0;

function getRI(max) {//获取数字
  return Math.floor(Math.random() * max);
}
function RWords(keyword) {
	var words = {
	morning : ["诶嘿，又是元气满满的一天！",
"没想到你比太阳起的还早啊～",
"昨天，来也匆匆，去也匆匆，绚丽多彩的一天又开始了，嘿嘿",
"早安，太阳，早安，地球，早安，武功，早安，可爱的你啊～"],
	noon : ["还不饿吗，快快去吃饭！！！",
"哇哦，是哪个好奇的小盆友还在看呐，中午了哦",
"一天又过半了，午好呐午好～",
"叮咚～午饭时间到，我这有个苹果，分你一半！"],
	afternoon : ["下午的阳光真是舒适哇",
"要来杯下午茶嘛，我请客哦",
"巴适！真是开心的一天啊＼(^▽^)／！",
"每天攒下一点快乐，这样你就是最快乐的小朋友了～下午好啊"],
	evening : ["呀！天黑了，吃晚饭了吗(^ω^)",
"抬头看看，★星星★出来喽～",
"白天学习，顺其自然，晚上早睡，精力充沛！！",
"我去天上劫了一颗星星，送去陪你过夜～"],
	midNight : ["让我看看是哪个夜猫子还不睡啊～",
"哦豁，你是要等到太阳出来吗！快去睡觉！",
"看见天上那忽闪忽闪的星星了嘛，这代表着有人在想你哦～",
"我都困了，你怎么还不睡呀(￣▽￣)～"]
	};//定义问候语
	switch (keyword) {//根据传入的 关键词 选择 问候语
		case "morning":
			tem = words.morning;
			return tem[getRI(tem.length - 1)];
		break;
		case "noon":
			tem = words.noon;
			return tem[getRI(tem.length - 1)];
		break;
		case "afternoon":
			tem = words.afternoon;
			return tem[getRI(tem.length - 1)];
		break;
		case "evening":
			tem = words.evening;
			return tem[getRI(tem.length - 1)];
		break;
		case "midNight":
			tem = words.midNight;
			return tem[getRI(tem.length - 1)];
		break;
	}
}
function TChange(keyword) {
	var TText = RWords(keyword);//获取问候语
	tem = keyWords;
	keyWords = TText;
	setTimeout(function(text){
		keyWords = text;//使keyWords为text
		setTimeout(
		function(){TChange(keyword);//进入循环
		},1000 * Ctime
		);
	},1000 * Ctime,tem);
}
function titleChange() {
	var keyList = keyWords.split("");
	var firstChar = keyList.shift();
	Ctime = keyList.length;
	keyList.push(firstChar);
	keyWords = keyList.join("");
	document.title = keyWords;
	setTimeout(titleChange, 70 * Ctime);
}
function THello() {
	var titleObj = document.title;//获取标题文本
	var time = new Date().getHours();//获取当前时间
	if (time >= 6 && time <= 9) {//判断时间
		keyWords = "早啊～(●﹏● ";
		TChange("morning");
	}
	else if (time >= 10 && time <= 13) {
		keyWords = "午安～(^ω^ ";
		TChange("noon");
	}
	else if (time >= 14 && time <= 17) {
		keyWords = "下午好～ \(^0^ ";
		TChange("afternoon");
	}
	else if (time >= 18 && time <= 23) {
		keyWords = "晚啊～ (≥﹏≤ ";
		TChange("evening");
	}
	else {
		keyWords = "这么晚还没睡吗～ (⊙▽⊙ ";
		TChange("midNight");
	}
}
setTimeout(function(){
	THello();
	titleChange();
},10000)